import { createRouter, createWebHashHistory } from 'vue-router';
import Layout from '@/layout/index.vue';
import Home from './Home';

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      name: 'home',
      redirect: '/home/zonghe'
    },
    // 登录
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/Login/index.vue')
    },
    // 数据集评分
    {
      path: '/home',
      name: 'zonghe',
      component: Layout,
      redirect: '/home/zonghe',
      children: Home
    },
  ]
})
// 路由拦截 
// router.beforeEach((to, from, next) => {
//   const token = sessionStorage.getItem('token');
//   if (token) {
//     if(to.path === '/login' || to.path === '/') {
//       next('/')
//     };
//     next();
//   } else {
//     if (to.path !== '/login') {
//       next('/login');
//     } else {
//       next();
//     }
//   }
// });
export default router
